# -*- coding: utf-8 -*-
# @Time    : 2018/8/14 13:00
# @Author  : 聂家利
# @Email   : 1073438012@qq.com
# @File    : http.py.py
# @Software: PyCharm

import requests


# scrapy, requests + beautiful soap 爬虫
# object 在python3 在类中无区别
# 新式类
class HTTP:
    """

    """
    @staticmethod
    def get(url, return_json=True):
        r = requests.get(url)
        if r.status_code != 200:
            return {} if return_json else ''  # 多用三元, return, 少用if else
        return r.json() if return_json else r.text